import type { ApiRequest } from '@/types/apis.d'
import type { AdItem } from '@/types/advertising/advertising'
import { request } from '../index'
export interface AdvertisingRequest {
  //广告管理
  'advertising.list_library': {
    id: number | string | undefined
    name: string | undefined
    status: number //1-开启 2-关闭
  }
  //添加广告库
  'advertising.add_library': {
    name: string
    icon_type: number
    icon_url: string
    intro: string
    status: number
  }
  //编辑广告库
  'advertising.update_library': {
    id?: number | string | undefined
    name: string
    icon_type: number
    icon_url: string
    intro: string
    status: number
  }
  //广告库详情
  'advertising.detail_library': { id: string | undefined }
  //删除广告库
  'advertising.delete_library': {
    id: string
  }
  //修改广告库状态
  'advertising.update_status_library': {
    id: string
    status: number
  }
  //广告库排序
  'advertising.library_order': {
    id: string
    order: number
  }
  //广告排序
  'advertising.advertising_order': {
    id: string
    order: number
  }
  //广告列表
  'advertising.list': {
    library_id: string
    id: string | undefined
    name: string | undefined
    status: number | undefined //1-开启 2-关闭
    adv_type: number
    limit: number
    offset?: number
    sort?: string
    order?: number
    /**
     * StartAdv: 启动广告
        PopAdv: 弹窗广告
        CarouselAdv: 轮播广告
        BannerAdv: 横幅广告
        BottomAdv: 底部广告
        BeforePlayAdv: 播放前广告
        SuspendPlayAdv: 播放暂停广告
        ColumnAdv: 专栏广告
        1: 启动广告
        2: 弹窗广告
        3: 轮播广告
        4: 横幅广告
        5: 底部广告
        6: 播放前广告
        7: 播放暂停广告
        8: 专栏广告
     */
  }
  //添加广告
  'advertising.add': {
    library_id?: string | undefined
    adv_type: number
    name: string
    img_type: number //图片或者文字
    img_url: string
    word_style?: string //文案样式
    jump_addr: string //跳转链接
    show_time?: number | undefined //显示时长
    status: number | undefined //1-开启 2-关闭
    show_position?: number[]
    [key: string]: any
  }
  //编辑广告
  'advertising.update': {
    id?: string | undefined
    adv_type: number
    name: string
    img_type: number //图片或者文字
    img_url: string
    word_style?: string //文案样式
    jump_addr: string //跳转链接
    show_time?: number | undefined //显示时长
    show_position?: number[]
    status: number | undefined //1-开启 2-关闭
    [key: string]: any
  }
  //广告详情
  'advertising.detail': { id: string | undefined }
  //设置轮播时长
  'advertising.set_slide_time': { show_time: number | undefined; adv_library_id: string }
  //获取轮播时间
  'advertising.get_showtime': {
    adv_library_id: string
  }
  //修改广告状态
  'advertising.update_status': {
    id: string
    status: number
  }
  //删除广告库
  'advertising.delete': {
    id: string
  }
  //批量删除广告库
  'advertising.delete_batch': {
    ids: string[]
  }
  //批量删除广告库
  'advertising.batch_update_status': {
    ids: string[]
    status: number
  }
  //广告位置统计
  'advertising.position': {
    adv_type: number
  }
}
//广告库列表
export const list_library = (params?: ApiRequest['advertising.list_library']) =>
  request.get<'advertising.list_library', AdItem[]>('v1/advertising/library/list', params)
//添加广告库
export const add_library = (data?: ApiRequest['advertising.add_library']) =>
  request.post<'advertising.add_library', any>('/v1/advertising/library/add', data)
//更新广告库
export const update_library = (data?: ApiRequest['advertising.update_library']) =>
  request.post<'advertising.update_library', any>('/v1/advertising/library/update', data)
// 删除广告库
export const delete_library = (params?: ApiRequest['advertising.delete_library']) =>
  request.get<'advertising.delete_library', any>(`v1/advertising/library/delete`, params)
//广告库详情
export const detail_library = (params?: ApiRequest['advertising.detail_library']) =>
  request.get<'advertising.detail_library', AdItem[]>('/v1/advertising/library/info', params)
//修改广告库状态
export const update_status_library = (data?: ApiRequest['advertising.update_status_library']) =>
  request.post<'advertising.update_status_library', any>('/v1/advertising/library/update_status', data)
//广告库排序
export const library_order = (data?: ApiRequest['advertising.library_order']) =>
  request.post<'advertising.library_order', any>('/v1/advertising/library/order', data)
//广告排序
export const advertising_order = (data?: ApiRequest['advertising.advertising_order']) =>
  request.post<'advertising.advertising_order', any>('/v1/advertising/order', data)
//广告列表
export const list = (params?: ApiRequest['advertising.list']) =>
  request.get<'advertising.list', AdItem[]>('/v1/advertising/list', params)
//添加广告
export const add = (data?: ApiRequest['advertising.add']) =>
  request.post<'advertising.add', any>('/v1/advertising/add', data)
//更新广告
export const update = (data?: ApiRequest['advertising.update']) =>
  request.post<'advertising.update', any>('/v1/advertising/update', data)
//广告详情
export const detail = (params?: ApiRequest['advertising.detail']) =>
  request.get<'advertising.detail', AdItem[]>('/v1/advertising/info', params)
//修改广告状态
export const update_status = (data?: ApiRequest['advertising.update_status']) =>
  request.post<'advertising.update_status', any>('/v1/advertising/update_status', data)
//设置轮播时长
export const set_slide_time = (data?: ApiRequest['advertising.set_slide_time']) =>
  request.post<'advertising.set_slide_time', any>('/v1/advertising/update_show_time', data)
//获取广告详情
export const get_showtime = (params?: ApiRequest['advertising.get_showtime']) =>
  request.get<'advertising.get_showtime', AdItem[]>('/v1/advertising/get_show_time', params)
// 删除广告
export const delete_ad = (params?: ApiRequest['advertising.delete']) =>
  request.get<'advertising.delete', any>(`/v1/advertising/delete`, params)
// 批量删除广告
export const delete_batch = (data?: ApiRequest['advertising.delete_batch']) =>
  request.post<'advertising.delete_batch', any>(`/v1/advertising/delete_batch`, data)

// 批量编辑广告状态
export const batch_update_status = (data?: ApiRequest['advertising.batch_update_status']) =>
  request.post<'advertising.batch_update_status', any>(`/v1/advertising/batch_update_status`, data)
//广告位置统计
export const position = (params?: ApiRequest['advertising.position']) =>
  request.get<'advertising.position', AdItem[]>('/v1/advertising/position', params)
//获取广告位列表
export const position_list = (params?: ApiRequest['manager.info']) =>
  request.get<'manager.info', any>(`v1/advertising/position/list`, params)
